/**
 * 日期转换
 * @type {exports}
 */
function numToDoubleChar(num) {
  return num < 10 ? '0' + num : num + '';
}

function dateFormat(date) {
  return date ?
  date.getFullYear() +
  numToDoubleChar(date.getMonth() + 1) +
  numToDoubleChar(date.getDate()) +
  numToDoubleChar(date.getHours()) +
  numToDoubleChar(date.getMinutes()) +
  numToDoubleChar(date.getSeconds())
    :
    '';
}

module.exports = {
  toStr: function (date) {
    return dateFormat(date);
  }
};